<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="年度" prop="statisticsDate">
        <el-date-picker
          v-model="statisticsDate"
          type="year"
          placeholder="年度"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="课程名称" prop="subjectName">
        <el-input
          v-model="queryParams.subjectName"
          placeholder="请输入课程名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['edu:classroom:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="statisticsDataList" show-summary>
      <el-table-column label="年度" align="center" prop="statisticsDate"/>
      <el-table-column label="课程名称" align="center" prop="subjectName"/>
      <el-table-column label="学生数量" align="center" prop="studentNumber"/>
      <el-table-column label="课消收入" align="center" prop="consumptionRevenue"/>
      <el-table-column label="课程应收" align="center" prop="subjectReceivables"/>
      <el-table-column label="课程未收" align="center" prop="subjectPendingPayments"/>
    </el-table>


  </div>
</template>

<script>
import { classConsumptionRevenue } from '@/api/statistics/statistics'

export default {
  name: 'ClassConsumptionRevenue',
  dicts: ['sys_weekDay'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 统计数据
      classConsumptionRevenueDataList: [],
      statisticsDate: new Date(),
      // 查询参数
      queryParams: {
        statisticsDate: null,
        subjectName: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    }
  },
  created() {

    this.getList()
  },
  methods: {
    /** 查询班级管理列表 */
    getList() {
      if (this.statisticsDate) {
        this.queryParams.statisticsDate = this.statisticsDate.getFullYear();
      }
      this.loading = true
      classConsumptionRevenue(this.queryParams).then(response => {
        this.statisticsDataList = response.data
        this.loading = false
      })
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('edu/classroom/export', {
        ...this.queryParams
      }, `room_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
